﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MyOA.BLL;
using MyOA.Model;

namespace MyOA.UI.ManualSign
{
    public partial class SignStatistic : System.Web.UI.Page
    {
        BranchInfoManager branchInfoManager = new BranchInfoManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["loginId"] == null)
            {
                Response.Redirect("~/Login.aspx");
                return;
            }
            if (!IsPostBack)
            {
                IList<BranchInfo> branchs = branchInfoManager.GetBranchName();
                BranchInfo bi = new BranchInfo();
                bi.BranchName = "==请选择==";
                bi.BranchId = -1;
                branchs.Add(bi);
                ddlBranchs.DataSource = branchs;
                ddlBranchs.DataTextField = "BranchName";
                ddlBranchs.DataValueField = "BranchId";
                ddlBranchs.SelectedIndex = branchs.Count - 1;//选中项的索引
                ddlBranchs.DataBind();
            }
        }

        protected void ddlBranchs_SelectedIndexChanged(object sender, EventArgs e)
        {
            int branchId = Convert.ToInt32(ddlBranchs.SelectedValue);//获得下拉列表的值
            ddlDeparts.DataTextField = "DepartName";
            ddlDeparts.DataSource = dataBindDepart(branchId);
            ddlDeparts.DataBind();
        }
        private IList<DepartInfo> dataBindDepart(int branchId)
        {
            DepartInfoManager dim = new DepartInfoManager();
            return dim.GetDepartName(branchId);//根据机构查询部门
        }
    }
}
